﻿<%@ Page Language="C#" %>

<%@ Import Namespace="wojilu" %>
<%@ Import Namespace="wojilu.View" %>
<%@ Import Namespace="wojilu.Apps.Qycms.Domain" %>
<%@ Import Namespace="wojilu.Apps.Qycms.Service" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>#{softtitle}</title>
<link href="#{path.css}ybb/css/baselist.css?v=#{cssVersion}" rel="stylesheet" type="text/css" />
<link href="#{path.css}ybb/css/all.css?v=#{cssVersion}" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="#{path.js}ybb/js/jquery.js?v=#{jsVersion}"></script>
    <script type="text/javascript" language="JavaScript">
        var createmain_doc_mess_title = "_{createmain_doc_mess_title}";
        var createmain_doc_mess_title2 = "_{createmain_doc_mess_title2}";
        var createmain_doc_mess_title3 = "_{createmain_doc_mess_title3}";
        var createmain_mess_title3 = "_{createmain_mess_title3}";
        var createmain_mess_title4 = "_{createmain_mess_title4}";
        var createmain_mess_title5 = "_{createmain_mess_title5}";
        var createmain_creat_yes = "_{createmain_creat_yes}";
        var createmain_creat_no = "_{createmain_creat_no}";
        var createmain_creat_no_c = "_{createmain_creat_no_c}";
        var createmain_creat_no_w = "_{createmain_creat_no_w}";
        var createmain_creat_no_t = "_{createmain_creat_no_t}";
        var createmain_creat_bottonname = "_{createmain_creat_bottonname}";
        var botton_close = "_{botton_close}";
        var createmain_creat_title = "_{createmain_creat_title}";
        var err_createmain_err_title = "_{err_createmain_err_title}";
        var createmain_js_add_ok = "_{createmain_js_add_ok}";
			var is_html = "#{is_html}";
			$(document).ready(function() {
				var h = $(window).height();
				$('#mainwindowhidden').css({height: h - 39});
				if (is_html == 1) {
					get_load();
				} else {
					$('#doccheckmanger').empty();
					$('#doccheckmanger').append(err_createmain_err_title);
				}
			});

			function get_load() {
				var loadurl = "<%=link.to(new wojilu.Web.Controller.Admin.Qycms.CreateController().Statype) %>?";
				$('#doccoasecreat').attr('disabled', 'true');
				$('#doccoasecreat').val(createmain_creat_bottonname);
				$('#docloadingline').css("width", 0);
				$.ajax({
					type: "POST",
					url: loadurl,
					dataType: 'json',
					data: "lng=#{lng}&mid=#{mid}&tid=#{tid}&creattype=1&startid=#{startid}&endid=#{endid}",
					success: function(date) {
						if (date.num > 0) {
							$('#doccheckmanger').remove();
							$('#doccheckloading').removeClass().addClass('formdiv displaytrue');
							var newHTML = createmain_doc_mess_title + '<b><u> ' + date.num + ' </u></b>' + createmain_doc_mess_title2;
							$("#docloadtext").append(newHTML);
							loadocnum(date.typelist);
						} else {
							$('#doccheckmanger').remove();
							$('#doccheckloading').removeClass().addClass('formdiv displaytrue');
							var newHTML = createmain_doc_mess_title + '<b><u> ' + date.num + ' </u></b>' + createmain_doc_mess_title2;
							$("#docloadtext").append(newHTML);
							$("#dochtmltext").append(createmain_js_add_ok);
							$('#doccoasecreat').val(botton_close);
							$('#doccoasecreat').attr('disabled', '');
						}
					}
				});
			}

			function loadocnum(typelist) {
				var loadurl = "<%=link.to(new wojilu.Web.Controller.Admin.Qycms.CreateController().DocNum) %>?";
				var limit=10;
				$.ajax({
					type: "POST",
					url: loadurl,
					data: "lng=#{lng}&mid=#{mid}&tid=" + typelist + "&startid=#{startid}&endid=#{endid}",
					success: function(date) {
						if (date > 0) {

							var limitnum = Math.round(date / limit + 1);

							var countmax = 500 / limitnum;

							var equanum = 100 / limitnum;

							$("#loadnum").empty().append(date);

							creatdoc(0, 0, limit, typelist, limitnum, countmax, equanum, 0, 0);
						} else if (date <= 0) {
							loadtxt(createmain_mess_title5, '500', '100%');
							$("#dochtmltext").append("<br>" + createmain_js_add_ok);
							$('#doccoasecreat').val(botton_close);
							$('#doccoasecreat').attr('disabled', '');
						}
					}
				});
			}

			function creatdoc(limitstart, i, limitnummax, typelist, limitnum, countmax, equanum, equ, width) {
				var loadurl = "<%=link.to(new wojilu.Web.Controller.Admin.Qycms.CreateController().CreatDocSave) %>?";

				var loadmum = limitstart + limitnummax;
				if (i < limitnum) {
					$.ajax({
						type: "POST",
						url: loadurl,
						data: "lng=#{lng}&mid=#{mid}&tid=" + typelist + "&limit=" + limitstart + "&limitnummax=" + limitnummax + "&startid=#{startid}&endid=#{endid}",
						success: function(date) {
							if (date == 'true') {

								width = width + countmax;
								equ = equ + equanum;
								var text = parseInt(equ) + "%";
								var loadstr = limitstart + ' - ' + loadmum;
								loadtxt(loadstr, width, text);

								i++;

								limitstart = i * limitnummax;
								creatdoc(limitstart, i, limitnummax, typelist, limitnum, countmax, equanum, equ, width);
							}
						}
					});
				} else {
					$("#dochtmltext").append("<br>" + createmain_js_add_ok);
					$('#doccoasecreat').val(botton_close);
					$('#doccoasecreat').attr('disabled', '');
				}
			}

			function loadtxt(date, width, text) {
				if (date == 'false')
					return false;
				var str = date + createmain_doc_mess_title3+'<br/>';
				$("#dochtmltext").empty().append(str);
				$('#docloadingline').css("width", width);
				$("#docloadingline").empty().append(text);
			}
			function loadclose() {
				parent.closeifram();
			}

		</script>
</head>

<body>
<div class="centerrightwindow">
<div id="mainwindowhidden">
	<div class="suggestion">
		<span class="sugicon"><span class="strong colorgorning2">_{position_title}</span><span class="padding-left5 colorgorningage">_{createmain_creattype_title}</span></span>
	</div>
		<div class="sugtitle-line"></div>
		<div class="formdiv" id="doccheckmanger">
			<table border="0" width="100%">
				<tr>
					<td id="center" style="padding:25px;"><img alt="" src="#{path.img}ybb/images/loading_02.gif" /></td>
				</tr>
				<tr>
					<td id="center" class="strong colorgorning2" style="padding:0px">_{loading_title_mess}</td>
				</tr>
			</table>
		</div>
		<div class="formdiv displaynone" id="doccheckloading">
			<table border="0" width="100%">
				<tr>
					<td id="docloadtext" style="padding-top:10px;" class="colorgorning2 center lineheight160"></td>
				</tr>
				<tr>
					<td width="100%" style="padding-top:10px;" class="center">
						<div class="loadingtable" id="loadingtable">
							<div class="loadingline" id="docloadingline">0</div>
						</div>
					</td>
				</tr>
				<tr>
					<td id="dochtmltext" style="padding-top:5px;" class="colorgorningage center lineheight160"></td>
				</tr>
			</table>
		</div>
	</div>
	<div id="downbotton">
		<div id="subbotton">
			<table border="0" width="100%">
				<tr id="bottonsubmit">
					<td id="center"><input type="button" name="cancel" id="doccoasecreat" onClick="javascript:loadclose();" value="_{botton_close}" class="buttonface"/></td>
				</tr>
			</table>
		</div>
	</div>
</div>
</body>
</html>
